if(NOT "${GMP_LIBRARY_TYPE}" STREQUAL "STATIC" AND NOT "${GMP_LIBRARY_TYPE}" STREQUAL "SHARED")
    set(GMP_LIBRARY_TYPE "@GMP_LIBRARY_TYPE@")
endif()
set(LIB_PREFIX "${CMAKE_${GMP_LIBRARY_TYPE}_LIBRARY_PREFIX}")
set(LIB_SUFFIX "${CMAKE_${GMP_LIBRARY_TYPE}_LIBRARY_SUFFIX}")

set(GMPXX_INCLUDE_PATHS "@INSTALL_CONFIG_INCLUDE_PATHS@")
set(GMPXX_LIB_PATHS "@INSTALL_CONFIG_LIB_PATHS@")

unset(GMPXX_INCLUDE_DIR CACHE)
unset(GMPXX_LIBRARY CACHE)

find_path(GMPXX_INCLUDE_DIR gmpxx.h PATHS ${GMPXX_INCLUDE_PATHS})
find_library(GMPXX_LIBRARY NAMES ${LIB_PREFIX}gmpxx${LIB_SUFFIX} PATHS ${GMPXX_LIB_PATHS})

if(EXISTS "${GMPXX_INCLUDE_DIR}" AND EXISTS "${GMPXX_LIBRARY}")
    set(GMPXX_FOUND TRUE)
else()
    set(GMPXX_LIBRARY )
    set(GMPXX_FOUND FALSE)
endif()

if(GMPXX_FOUND AND NOT TARGET GMP::GMPXX)
    add_library(GMP::GMPXX "${GMP_LIBRARY_TYPE}" IMPORTED)
    set_target_properties(GMP::GMPXX PROPERTIES
                                     IMPORTED_LOCATION "${GMPXX_LIBRARY}"
                                     INTERFACE_INCLUDE_DIRECTORIES "${GMPXX_INCLUDE_DIR}")
endif()

mark_as_advanced(
    GMPXX_INCLUDE_DIR
    GMPXX_LIBRARY
)
